package com.econ.powercloud.ems.common.enums;

import java.util.Objects;

/**
 * @author jwc
 * @date 2022/11/11
 */
public enum DitTypeEnum implements EnumMethod {
    YX(1, "遥信"),
    YC(2, "遥测"),
    CAL_YX(3, "计算遥信"),
    CAL_YC(4, "计算遥测"),
    YK(5, "遥控"),
    YT(6, "遥调"),
    JH(7,"计划");


    private Integer code;
    private String desc;

    DitTypeEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getDesc() {
        return desc;
    }

    public static DitTypeEnum fromCode(int code){
        for(DitTypeEnum e: DitTypeEnum.values()){
            if(e.getCode() == code){
                return e;
            }
        }
        return YC;
    }

    public static String getDescFromCode(int code){
        for(DitTypeEnum e: DitTypeEnum.values()){
            if(e.getCode() == code){
                return e.getDesc();
            }
        }
        return "";
    }

    /**
     * 判断是否是实时数据
     */
    public static boolean isFlashData(int code){
        return Objects.equals(DitTypeEnum.YX.getCode(),code) || Objects.equals(DitTypeEnum.YC.getCode(),code);
    }

    /**
     * 判断是否是计算数据
     */
    public static boolean isCalData(int code){
        return Objects.equals(DitTypeEnum.CAL_YX.getCode(),code) || Objects.equals(DitTypeEnum.CAL_YC.getCode(),code);
    }

    /**
     * 判断是否是遥测数据(主要用于查询历史数据)
     */
    public static boolean isYcData(int code){
        return Objects.equals(DitTypeEnum.YC.getCode(),code) || Objects.equals(DitTypeEnum.CAL_YC.getCode(),code);
    }

    /**
     * 判断是否是遥信数据(主要用户查询历史数据)
     */
    public static boolean isYxData(int code){
        return Objects.equals(DitTypeEnum.YX.getCode(),code) || Objects.equals(DitTypeEnum.CAL_YX.getCode(),code);
    }

    /**
     * 判断是否是遥控/遥调
     */
    public static boolean isYkYt(int code){
        return Objects.equals(DitTypeEnum.YK.getCode(),code) || Objects.equals(DitTypeEnum.YT.getCode(),code);
    }

}
